home *** CD-ROM | disk | FTP | other *** search
/ Let's Discover North Carolina / Let's Discover North Carolina.iso / pc / FILES / TIME.dxr / 00006_Slide.ls < prev    next >
Encoding:
Text File  |  2000-12-01  |  7.9 KB  |  179 lines

  1. property appearWhen, slideDuration, direction, spriteNum, mySprite, myStartFrame, myEndFrame, myOriginalMember, myOriginalImage, myTransitionMember
  2.  
  3. on beginSprite me
  4.   me.convertAppearance()
  5.   me.convertDirection()
  6.   mySprite = sprite(spriteNum)
  7.   myOriginalMember = mySprite.member
  8.   myOriginalImage = image(myOriginalMember.width, myOriginalMember.height, 32)
  9.   case myOriginalMember.type of
  10.     #bitmap:
  11.       myOriginalImage = myOriginalMember.image
  12.       if not myOriginalMember.useAlpha then
  13.         myOriginalImage.setAlpha(255)
  14.       end if
  15.     #text, #vectorShape, #flash:
  16.       if myOriginalMember.type = #text then
  17.         mySprite.rect = mySprite.rect
  18.       end if
  19.       if mySprite.ink = 0 then
  20.         case myOriginalMember.type of
  21.           #text, #flash:
  22.             myOriginalImage.fill(myOriginalImage.rect, myOriginalMember.bgColor)
  23.           #vectorShape:
  24.             myOriginalImage.fill(myOriginalImage.rect, myOriginalMember.backgroundColor)
  25.         end case
  26.         myOriginalImage.copyPixels(myOriginalMember.image, myOriginalMember.rect, myOriginalImage.rect, [#maskImage: myOriginalMember.image.extractAlpha()])
  27.       else
  28.         myOriginalImage = myOriginalMember.image
  29.       end if
  30.   end case
  31.   case appearWhen of
  32.     #start:
  33.       myStartFrame = mySprite.startFrame
  34.       myEndFrame = myStartFrame + slideDuration - 1
  35.     #end:
  36.       myEndFrame = mySprite.endFrame
  37.       myStartFrame = myEndFrame - slideDuration + 1
  38.   end case
  39.   myTransitionMember = new(#bitmap, castLib(mySprite.castLibNum))
  40.   myTransitionMember.image = image(myOriginalMember.width, myOriginalMember.height, 32, 8)
  41.   myTransitionMember.regPoint = myOriginalMember.regPoint
  42.   myTransitionMember.useAlpha = 1
  43. end
  44.  
  45. on endSprite me
  46.   mySprite.member = myOriginalMember
  47.   erase(myTransitionMember)
  48. end
  49.  
  50. on prepareFrame me
  51.   if (the frame >= myStartFrame) and (the frame <= myEndFrame) then
  52.     elapsedFrames = the frame - myStartFrame + 1
  53.     if appearWhen = #end then
  54.       elapsedFrames = slideDuration - elapsedFrames
  55.     end if
  56.     memberRect = myTransitionMember.rect
  57.     case direction of
  58.       #lefttoright, #righttoleft:
  59.         imageRect = memberRect * rect(1, 1, elapsedFrames, 1) / rect(1, 1, slideDuration, 1)
  60.       #bottomtotop, #toptobottom:
  61.         imageRect = memberRect * rect(1, 1, 1, elapsedFrames) / rect(1, 1, 1, slideDuration)
  62.       otherwise:
  63.         imageRect = memberRect * rect(1, 1, elapsedFrames, elapsedFrames) / rect(1, 1, slideDuration, slideDuration)
  64.     end case
  65.     destRect = imageRect
  66.     case appearWhen of
  67.       #start:
  68.         case direction of
  69.           #lefttoright:
  70.             imageRect = offset(imageRect, memberRect.width - imageRect.width, 0)
  71.           #righttoleft:
  72.             destRect = offset(destRect, memberRect.width - imageRect.width, 0)
  73.           #toptobottom:
  74.             imageRect = offset(imageRect, 0, memberRect.height - imageRect.height)
  75.           #bottomtotop:
  76.             destRect = offset(destRect, 0, memberRect.height - imageRect.height)
  77.           #bottomrighttotopleft:
  78.             destRect = offset(destRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height)
  79.           #bottomlefttotopright:
  80.             imageRect = offset(imageRect, memberRect.width - imageRect.width, 0)
  81.             destRect = offset(destRect, 0, memberRect.height - imageRect.height)
  82.           #toprighttobottomleft:
  83.             imageRect = offset(imageRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height)
  84.           #toplefttobottomright:
  85.             destRect = offset(imageRect, memberRect.width - imageRect.width, 0)
  86.             imageRect = offset(imageRect, 0, memberRect.height - imageRect.height)
  87.         end case
  88.       #end:
  89.         case direction of
  90.           #righttoleft:
  91.             imageRect = offset(imageRect, memberRect.width - imageRect.width, 0)
  92.           #lefttoright:
  93.             destRect = offset(destRect, memberRect.width - imageRect.width, 0)
  94.           #bottomtotop:
  95.             imageRect = offset(imageRect, 0, memberRect.height - imageRect.height)
  96.           #toptobottom:
  97.             destRect = offset(destRect, 0, memberRect.height - imageRect.height)
  98.           #toprighttobottomleft:
  99.             destRect = offset(destRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height)
  100.           #toplefttobottomright:
  101.             imageRect = offset(imageRect, memberRect.width - imageRect.width, 0)
  102.             destRect = offset(destRect, 0, memberRect.height - imageRect.height)
  103.           #bottomrighttotopleft:
  104.             imageRect = offset(imageRect, memberRect.width - imageRect.width, memberRect.height - imageRect.height)
  105.           #bottomlefttotopright:
  106.             destRect = offset(imageRect, memberRect.width - imageRect.width, 0)
  107.             imageRect = offset(imageRect, 0, memberRect.height - imageRect.height)
  108.         end case
  109.     end case
  110.     myTransitionMember.image.setAlpha(0)
  111.     myTransitionMember.image.copyPixels(myOriginalImage, destRect, imageRect)
  112.     myTransitionMember.image.useAlpha = 1
  113.     mySprite.member = myTransitionMember
  114.   else
  115.     mySprite.member = myOriginalMember
  116.   end if
  117. end
  118.  
  119. on convertAppearance me
  120.   case appearWhen of
  121.     "beginning of sprite":
  122.       appearWhen = #start
  123.     "end of sprite":
  124.       appearWhen = #end
  125.   end case
  126. end
  127.  
  128. on convertDirection me
  129.   case direction of
  130.     "left to right":
  131.       direction = #lefttoright
  132.     "right to left":
  133.       direction = #righttoleft
  134.     "bottom to top":
  135.       direction = #bottomtotop
  136.     "top to bottom":
  137.       direction = #toptobottom
  138.     "bottom left to top right":
  139.       direction = #bottomlefttotopright
  140.     "bottom right to top left":
  141.       direction = #bottomrighttotopleft
  142.     "top right to bottom left":
  143.       direction = #toprighttobottomleft
  144.     "top left to bottom right":
  145.       direction = #toplefttobottomright
  146.   end case
  147. end
  148.  
  149. on isOKToAttach me, aSpriteType, aSpriteNum
  150.   isOK = 0
  151.   case aSpriteType of
  152.     #graphic:
  153.       case sprite(aSpriteNum).member.type of
  154.         #bitmap, #text, #flash, #vectorShape:
  155.           isOK = 1
  156.       end case
  157.   end case
  158.   return isOK
  159. end
  160.  
  161. on getPropertyDescriptionList me
  162.   props = [:]
  163.   props[#appearWhen] = [#comment: "When transition appears:", #format: #string, #default: "beginning of sprite", #range: ["beginning of sprite", "end of sprite"]]
  164.   firstFrame = sprite(the currentSpriteNum).startFrame
  165.   endFrame = sprite(the currentSpriteNum).endFrame
  166.   maxLength = endFrame - firstFrame + 1
  167.   props[#slideDuration] = [#comment: "Duration:", #format: #integer, #default: min(maxLength, 10), #range: [#min: 1, #max: maxLength]]
  168.   props[#direction] = [#comment: "Direction:", #format: #string, #default: "left to right", #range: ["left to right", "right to left", "bottom to top", "top to bottom", "bottom left to top right", "bottom right to top left", "top right to bottom left", "top left to bottom right"]]
  169.   return props
  170. end
  171.  
  172. on getBehaviorTooltip
  173.   return "Use this behavior to make a sprite slide onto (or off of) the Stage from under the background."
  174. end
  175.  
  176. on getBehaviorDescription
  177.   return "SLIDE TRANSITION" & RETURN & RETURN & "Drop this behavior onto a sprite to create an animation of the sprite sliding under the background image. " & "The transition can make the sprite slide out from under the background, or slide under the background from its fully-revealed position. " & "Maintains alpha channel masks for 32-bit bitmaps." & RETURN & RETURN & "Select when the transition will take effect. " & "The duration controls the number of frames over which the transition occurs. " & "Direction controls the movement of the sprite." & RETURN & RETURN & "When this transition is used during authoring, and the movie is stopped the cast member it uses for the transition effect may not be erased." & RETURN & RETURN & "PERMITTED MEMBER TYPES:" & RETURN & "bitmaps and text" & RETURN & RETURN & "PARAMETERS:" & RETURN & "* When transition appears - controls whether sprite moves on or off the stage" & RETURN & "* Duration - number of frames for the transition to take place" & RETURN & "* Direction - movement of sprite onto or off of the stage"
  178. end
  179.